﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Zero.UControl.Base.Models;

namespace Zero.UControl.Component
{
    public class CascaderItemTemplateSelector : DataTemplateSelector
    {
        public DataTemplate CheckTemplate { get; set; }
        public DataTemplate RadioTemplate { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            var element = container as FrameworkElement;
            var cascaderItem = item as CascaderItem;
            if (element == null || cascaderItem == null)
                return RadioTemplate;

            return cascaderItem.IsMultiSelect && cascaderItem.HasChildren == false ? CheckTemplate : RadioTemplate;
        }
    }
}
